DragManager (CreateJS) Class
Drag manager is responsible for handling the dragging of stage elements. Supports click-n-stick (click to start, move mouse, click to release) and click-n-drag (standard dragging) functionality.
Constructor
Item Index
Methods
Properties
- _dragEndCallback
- _draggableObjects
- _dragOffset
- _dragStartCallback
- _helperPoint
- _stageMouseUpCallback
- _theStage
- _triggerHeldDragCallback
- _triggerStickyClickCallback
- _updateCallback
- allowStickyClick
- draggedObj
- dragStartThreshold
- isHeldDrag
- isStickyClick
- isTouchMove
- mouseDownObjPos
- mouseDownStagePos
- snapSettings
Methods
_handlePointSnap
-
localMousePos
Handles snapping the dragged object to the nearest among a list of points
Parameters:
-
localMousePos
createjs.PointThe mouse position in the same space as the dragged object.
_objMouseDown
-
ev
-
object
Mouse down on an obmect
Parameters:
-
ev
createjs.MouseEventA mouse down event to listen to to determine what type of drag should be used.
-
object
createjs.DisplayObjectThe object that should be dragged.
_startDrag
()
private
Internal start dragging on the stage
_stopDrag
-
ev
-
doCallback
Internal stop dragging on the stage
Parameters:
-
ev
createjs.MouseEventMouse up event
-
doCallback
BoolIf we should do the callback
_triggerHeldDrag
-
ev
Start hold dragging
Parameters:
-
ev
createjs.MouseEventThe mouse down event
_triggerStickyClick
()
private
Start the sticky click
_updateObjPosition
-
e
Update the object position based on the mouse
Parameters:
-
e
createjs.MouseEventMouse move event
addObject
-
obj
-
bound
Adds properties and functions to the object - use enableDrag() and disableDrag() on objects to enable/disable them (they start out disabled). Properties added to objects: _dragBounds (Rectangle), _onMouseDownListener (Function), _dragMan (cloudkid.DragManager) reference to the DragManager these will override any existing properties of the same name
Parameters:
-
obj
createjs.DisplayObjectThe display object
-
bound
createjs.RectangleThe rectangle bounds
destroy
()
public
Destroy the manager
initialize
-
startCallback
-
endCallback
Constructor
removeObject
-
obj
Removes properties and functions added by addObject().
Parameters:
-
obj
createjs.DisplayObjectThe display object
startDrag
-
object
-
ev
Manually starts dragging an object. If a mouse down event is not supplied as the second argument, it defaults to a held drag, that ends as soon as the mouse is released.
Parameters:
-
object
createjs.DisplayObjectThe object that should be dragged.
-
ev
createjs.MouseEventA mouse down event to listen to to determine what type of drag should be used.
stopDrag
-
doCallback
Stops dragging the currently dragged object.
Parameters:
-
doCallback
BoolIf the drag end callback should be called. Default is false.
Properties
_dragOffset
createjs.Point
private
The local to global position of the drag
_helperPoint
createjs.Point
private
A point for reuse instead of lots of object creation.
_theStage
CreatejsStage
private
Reference to the stage
allowStickyClick
Bool
public
If sticky click dragging is allowed.
Default: true
draggedObj
createjs.DisplayObject
public
The object that's being dragged
dragStartThreshold
Unknown
public
The radius in pixel to allow for dragging, or else does sticky click
Default: 20
isHeldDrag
Bool
public
Is the drag being held on mouse down (not sticky clicking)
Default: false
isStickyClick
Bool
public
Is the drag a sticky clicking (click on a item, then mouse the mouse)
Default: false
isTouchMove
Bool
public
Is the move touch based
Default: false
snapSettings
Object
public
Settings for snapping.
Format for snapping to a list of points: { mode:"points", dist:20,//snap when within 20 pixels/units points:[ { x: 20, y:30 }, { x: 50, y:10 } ] }
Default: null